﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script>
    <script type="text/javascript">
    
        window.onerror = MyErrorHandler;

        var map = null;
        var points = null;
        var icon = null;
        
        function LoadPage() {
            WriteBoilerplate();
            SetupMap();
        }
        
        // WriteBoilerplate

        // SetupMap
        
        // sends errors to SpatialAlbum host for processing
        function MyErrorHandler(message, url, line) {
            window.external.OnWebpageError(message, url, line);
            return true;
        }

        // tells SpatialAlbum host that the user clicked on a shape
        function OnPhotoClickHostCallback(e) {
            if (e.elementID) {
                var id = map.GetShapeByID(e.elementID).GetID();
                window.external.OnPhotoClick(id);
            }
        }

        // tells SpatialAlbum host that the user double-clicked on a shape
        function OnPhotoDoubleClickHostCallback(e) {
            if (e.elementID) {
                var id = map.GetShapeByID(e.elementID).GetID();
                window.external.OnPhotoDoubleClick(id);
                return true; // disable default action (to zoom in)
            }
        }

        // called by SpatialAlbum host to signal that a batch of photos are going to come in
        function BeginAddingPhotos() {
            //alert("BeginAddingPhotos");
            points = new Array();
            if (map) map.Clear();
        }
        
        // called by SpatialAlbum host to add a photo to the map
        function AddPhoto(latitude, longitude, title, description, thumbnailurl) {
            //alert("AddPhoto");
            var pnt = new VELatLong(latitude, longitude);
            points[points.length] = pnt;
            var shape = new VEShape(VEShapeType.Pushpin, pnt);
            shape.SetTitle('<center>' + title + '</center>');
            shape.SetDescription('<center>' + description + '<br><img src="' + thumbnailurl + '"></center>');
            if (icon) shape.SetCustomIcon(icon);
            map.AddShape(shape);
            return shape.GetID();
        }
        
        // called by SpatialAlbum host to signal that the batch of photo loading has ended
        function EndAddingPhotos() {
            //alert("EndAddingPhotos");
            if (points.length > 0)
                 map.SetMapView(points);
        }
        
        // called by SpatialAlbum host to set the image to be used for the photo points
        function SetIcon(iconurl) {
            //alert("SetIcon: " + iconurl);
            icon = iconurl;
        }
        
        // called by SpatialAlbum host to pan the map to a given location
        function PanTo(latitude, longitude) {
            var pnt = new VELatLong(latitude, longitude);
            //alert("PanTo - lat: " + latitude + " long: " + longitude);
            map.PanToLatLong(pnt);
        }
      
      </script>

</head>
<body onload="LoadPage();">
    <!-- AddMapDiv -->
    
    <!-- the MapDiv created in place of the line above will look somewhat like the MapDiv on the next line -->
    <!--div id="MapDiv" style="position:relative; width:auto; height:400px;"></div-->
    <!--div id="Boilerplate" style="height: 30px"></div-->
    <div id="Boilerplate"></div>
</body>
</html>
